package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;
//model layer package has to be imported
/**
 * Controller class for the DVD collection
 * 
 * @author (kbh) 
 * @version (2005.03.31)
 * @revised version English (Ab)
 * (FEN): 2006.03.21: Some changes to the architecture in order to assure layering
 *                    and loose coupling
 */
public class DVDCtr
{
    //declare instance variables to reference containers
    private DvdContainer dvdContainer;
    private DVD dvd;


    /**
     * Constructor for objects of class DVDCtr
     */
    public DVDCtr()
    {
       dvdContainer = new DvdContainer(); //set up references to containers    
    }
    
    //Dummy implementation: after implementing the model layer 
    //objects of class DVD are to be returned, not String
    public DVD findDVD(int id)
    {
       DVD dvd = dvdContainer.findDVD(id);

       return dvd; 
    }
    
    //Dummy implementation: more parameters are probaly to added
    public void createDVD(int id, String title, String author, String publicationDate)
    {       
          DVD dvd = new DVD(id, title, author, publicationDate);//this method constructs a new dvd object 
          dvdContainer.addDVD(dvd);//and stores it in the container
    }
    
    public void deleteDVD(int id)
    {
        
        //search for the dvd and delete the object from the container
       dvdContainer.removeDVD(id);
    }
    
    public void createCopy(int idOfDvd, int serialNumberOfCopy,String  purchaseDateOfCopy, double purchasePriceOfCopy)
    {
        DVD dvd = findDVD(idOfDvd);
        Copy copy = new Copy(serialNumberOfCopy, purchaseDateOfCopy, purchasePriceOfCopy);
        dvd.addCopy(copy);

}
    public void updateDVD(int id, String title, String author, String publicationDate)
    {
        dvdContainer.updateDVD( id, title,  author,  publicationDate);
    }
     public ArrayList listAllDvds()
    {
        dvdContainer.makedvdList();
        return null;
    }

    public void updateCopy(int id, int serialNumber, String purchaseDate, double purchasePrice)
    {
        
    }
    public void deleteCopy(int idOfDvd, int serialNumber)
    {
        DVD dvd = findDVD(idOfDvd);
        dvd.removeCopy(serialNumber);
}
public Copy findCopy(int id, int serialNumber)
{
    DVD dvd = findDVD(id);

    Copy copy = dvd.findCopy(serialNumber);
    return copy;
}
public int showDVDListSize()
{
    return dvdContainer.showDVDListSize();
}}
